<?xml version="1.0" encoding="UTF-8"?>  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:c="http://java.sun.com/jsp/jstl/core">
      
    <h:head>
    
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	 	<link rel="stylesheet" type="text/css" href="#{request.contextPath}/css/theme2.css" media="screen" />
	 	<link rel="stylesheet" type="text/css" href="#{request.contextPath}/css/estilo.css" media="screen" />  
		
		<script type="text/javascript">
		/* <![CDATA[ */
		var $j = jQuery.noConflict();
		/* ]]> */
	</script>
		
		  <h:outputScript library="js" name="util.js" target="form" />
		  
		  <h:outputScript library="js" name="meiomask.min.js" target="form" />
		  <ui:insert name="includeScript" />
		<title>
			<ui:insert name="tituloPagina">
				<h:outputText value="Novo Projeto Padr&#227;o" />
			</ui:insert>
		</title>
	</h:head>
	
	<h:body>
	<div id="geral">
	
	  	<div id="topo">
	  		<ui:include src="/pages/topo.xhtml" />
	  	</div>
	  	
	  	<div id="menu">
	  		<ui:include src="/pages/menu.xhtml" />
	  	</div>

	  	<ui:insert name="parametros">
			<ui:param name="bean" value="#{value}" />
		</ui:insert>
		
	  	<h:panelGroup id="painelGlobal">
	  		<div id="conteudo">
	  		  <h:form id="formConsulta">
    		     <h:panelGroup id="pesquisa" rendered="#{bean['searching']}">		
				    <fieldset>
				       <legend> 
				       		<ui:insert name="tituloFieldSetFiltro">
				       			<h:outputText value="Campos da Consulta" />
				       		</ui:insert> 
				       </legend>
				  		
				  	   <ui:insert name="camposFiltro">
				  	   </ui:insert>
				  	
				  	  <div class="margemtop">
				  	      <ui:insert name="botoesFiltro">
					  		 <p:commandButton styleClass="btn btn-primary btn-sm"
										      value="Consultar"
										      onclick="carregando.show();"
										      actionListener="#{bean['find']}" 
										      oncomplete="carregando.hide();"
										      update=":painelGlobal" />
				  	      </ui:insert>
				  	</div>
				 </fieldset>
				 
				 <br />
				 
				 <ui:insert name="tituloPainel">
				 	<ui:param name="tituloPainel" value="Nenhum" />
				 </ui:insert>
				 
				 <p:panel header="#{tituloPainel}">
				 	<div align="right" style="margin-bottom: 10px;">
				 		<ui:insert name="botoesInsertFiltro">
							<p:commandButton value="Novo"
											 actionListener="#{bean['prepareInsert']}" 
											 onclick="carregando.show();" 
											 styleClass="btn btn-primary btn-sm" 
											 update=":painelGlobal" />
											 
							<p:commandButton value="Excluir" 
											 styleClass="botaoExcluir"
											 ajax="true"
											 style="display:none;"
											 onclick="showIf()" 
											 />
				 		</ui:insert>
					  </div> 
				 	  <ui:insert name="resultFiltro"/>
				 	  
				 </p:panel>
			 </h:panelGroup>
			</h:form>
			
			<h:form id="formCadastro">
			  <h:panelGroup id="cadastro" rendered="#{bean['updating']}">		
				<fieldset>
				    <legend>
				  	   <ui:insert name="tituloFieldSetInsert">
				  	   </ui:insert> 
				    </legend>
				  	
				   <ui:insert name="camposInsert">
				   </ui:insert>
				  		
				  	<div class="margemtop">
				  		<ui:insert name="botoesInsert">
				  			<p:commandButton styleClass="btn btn-success" 
											 value="Salvar"
											 actionListener="#{bean['save']}" 
											 rendered="#{bean['inserting']}" 
											 oncomplete="mensagemAviso.show();"
											 update=":painelGlobal" />
						
							<p:commandButton styleClass="btn btn-success" 
						 					 value="Atualizar"
								             actionListener="#{bean['update']}"
								 			 oncomplete="mensagemAviso.show();" 
											 rendered="#{bean['editing']}" 
											 update=":painelGlobal" />
						
							<p:commandButton styleClass="btn btn-default" 
											 value="Voltar"
											 actionListener="#{bean['cancel']}" 
											 immediate="true" 
											 update=":painelGlobal" />
				  		</ui:insert>
					</div>
				  	
				 </fieldset>
			   </h:panelGroup>
			 </h:form>
	  	</div>
	  	
	  	<h:form id="formPanel">
	  	  
	  	  <p:dialog id="carregando" header="Carregando" widgetVar="carregando"
	  	            closable="false"
	  	  			fixedCenter="true" modal="true" height="80" width="150" 
	  	  			showEffect="fade"  hideEffect="fade">  
      		  <h:graphicImage width="30" height="30" value="#{resource['img:ajax-loader.gif']}" style="dislay:block" /> 
			  <h:outputLabel value="Aguarde..." />
		  </p:dialog>
		  
		  <p:dialog id="mensagemAviso" width="400" header="Aviso" widgetVar="mensagemAviso"
		  		    fixedCenter="true" showEffect="fade"  hideEffect="fade" 
		  		    visible="#{not empty facesContext.maximumSeverity}" modal="true">
		             <h:panelGroup  id="painelMensagens">
						<span id="messages">
							<h:messages layout="table" infoClass="info" warnClass="warning" errorClass="error" fatalClass="error">
								<f:facet name="infoMarker">
					               <h:graphicImage width="16" height="16" value="#{resource['img:info.gif']}" /> 
					            </f:facet>                    
					            <f:facet name="warnMarker" >
						           <h:graphicImage width="16" height="16" value="#{resource['img:warning.gif']}" />   
						        </f:facet>
						        <f:facet name="errorMarker">
						           <h:graphicImage width="16" height="16" value="#{resource['img:warning.gif']}" />   
						        </f:facet>
					            <f:facet name="fatalMarker">
					              <h:graphicImage width="16" height="16" value="#{resource['img:warning.gif']}" />
					            </f:facet>
							  </h:messages>
						 </span>
						 <br clear="all" />
						 <div style="vertical-align: bottom; text-align: center">
						     <p:commandButton value=" OK " 
						     				  styleClass="btVerde"
										      onclick="mensagemAviso.hide();" 
										      ajax="true" />
							
						 </div>
					</h:panelGroup>	
		         </p:dialog>
		          <ui:insert name="modalInsert" />
		        </h:form>
		      </h:panelGroup>
		      
		      <h:form id="formExclusao">
		         <p:confirmDialog message="Deseja excluir o(s) registro(s) selecionado(s)?" id="alertaExclu"
		         				  header="Confirma&ccedil;&atilde;o de Opera&ccedil;&atilde;o" 
								  severity="alert" widgetVar="panel" modal="true">
						<p:commandButton value="Sim"
										 update=":painelGlobal"
										 ajax="true"
										 styleClass="disabled"
										 actionListener="#{bean['deleteAll']}"
										 onclick="panel.hide();carregando.show();" 
										 oncomplete="mensagemAviso.show();clearCheckbox();">
						</p:commandButton>
					    <p:commandButton value="N&atilde;o" onclick="panel.hide();" ajax="true" type="button" styleClass="disabled" />
				 </p:confirmDialog>	
		      </h:form>
	  
	  	<ui:include src="/pages/rodape.xhtml" />
	  	 
	</div>
  </h:body>
   
</html>